using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace TmxEditor
{
    public partial class CellEditorPopup : Form
    {
        private string _context;

        public CellEditorPopup()
        {
            InitializeComponent();
        }


        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            this.textBox1.SelectionStart = 0;
            this.textBox1.SelectionLength = 0;
        }

        protected override void OnClosing(CancelEventArgs e)
        {
            base.OnClosing(e);

            this.DialogResult = _isCancel ? DialogResult.Cancel : DialogResult.OK;
        }

        public string Content
        {
            get { return textBox1.Text; }
            set { textBox1.Text = value;  }
        }

        public string Context
        {
            get
            {
                return _context;
            }
            set
            {
                _context = value;
                this.Text = value;
            }
        }

        private bool _isCancel = false;
        private void CellEditorPopup_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyData == Keys.Escape)
            {
                _isCancel = true;
                this.Close();
            }
        }
    }
}